import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// const path = require('path')
// import path from 'path'
import { fileURLToPath } from 'url'
import ViteComponents, { ElementPlusResolver } from 'vite-plugin-components';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    ViteComponents({
      customComponentResolvers: [
        ElementPlusResolver({ importStyle: true }),
      ]
    })
  ],
  css: {
    // module: {hashPrefix: true},
    preprocessorOptions: [],
    postcss: {
      // plugins: [postcss,autoprefixer]
    }
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
  server: {
    host: "localhost",
    port: 3000,
    open: true,
    strictPort: false,
    https: false,
    // proxy: {
    //   ['/api']: {
    //     target: '192.168.1.191:15000/',
    //     ws: true,
    //     changeOrigin: true,
    //     rewrite: path => {
    //       console.log('path', path);
    //       return ''
    //     }
    //   }
    // }
  },
  build: {
    rollupOptions: {
      external: ['element-plus']
    }
  }
})
// export default defineConfig(vueConfig)
